<template>
	<div>
		<button @click="hello">内置事件的实现步骤</button>

		<User v-on:event1="doSome" v-on:event2="doSome"></User>

		<!-- 简写形式 -->
		<User @event1="doSome" @event2="doSome"></User>

		<!-- 准备一个组件，借助代码完成自定义事件 -->
		<User ref="user"></User>
	</div>
</template>

<script>
import User from './components/User.vue';
export default {
	name: 'App',
	components: { User },
	mounted() {
		// 绑定事件
		this.$bus.$on('eventx', this.test)



		// 给ref='user'的组件绑定event1事件，并且给event1事件绑定一个回调函数：doSome
		this.$refs.user.$on('event1', this.doSome)
		console.log(this.$refs.user)

		this.$refs.user.$on('event2', this.doSome)
	},
	methods: {
		hello() {
			console.log('hello vue!')
		},
		doSome(name, age, gender) {
			console.log(name, age, gender)
		},
		test(name) {
			console.log('####', name)
		}
	}
}

</script>